package dao;

import BaseQuery.BaseQuery;
import Jdbc.Employee;
import org.junit.Test;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

public class TestDao1 {
	@Test
	public void TestAdd() throws SQLException {
		Employee employee = new Employee(null, "jack", "销售", new Date(), 8000.0, 20);
		EmployeeDao1 EmployeeDao1 = new EmployeeDao1();
		//System.out.println(EmployeeDao1.add(employee));
		int len = EmployeeDao1.add(employee);
		System.out.println("添加了" + len + "条记录");
	}

	@Test
	public void TestUpdate() throws SQLException {
		Employee employee = new Employee(8889, "jacj", "经理", new Date(), 5000.0, 30);
		EmployeeDao1 EmployeeDao1 = new EmployeeDao1();
		int len = EmployeeDao1.update(employee);
		System.out.println("添加了" + len + "条记录");
	}

	@Test
	public void TestgetById() throws Exception {
		Employee employee=new Employee();
		EmployeeDao1 EmployeeDao1=new EmployeeDao1();
		Employee emp=EmployeeDao1.getById(8889);
		System.out.println(emp);
	}
	@Test
	public void testGetAll() throws Exception {
		EmployeeDao1 EmployeeDao1 = new EmployeeDao1();
		List<Employee> employeeList = EmployeeDao1.getAll();
		employeeList.forEach(System.out::println);
	}
	@Test
	public void testGetByEname() throws Exception {
		EmployeeDao1 EmployeeDao1=new EmployeeDao1();
		List<Employee> list= EmployeeDao1.getByEname("A");
		list.forEach(System.out::println);
	}
	@Test
	public void  getByPage() throws Exception {
		BaseQuery baseQuery=new BaseQuery();
		EmployeeDao1 EmployeeDao1=new EmployeeDao1();
		List<Employee> list= EmployeeDao1.getByPage(baseQuery);
		list.forEach(System.out::println);
	}
	@Test
	public void getCountTatal() throws Exception {
		EmployeeDao1 employeeDao1=new EmployeeDao1();
		int len=employeeDao1.getCount();
		System.out.println("共有记录: "+len);
	}
}
